package org.ipp4j.core;

import org.ipp4j.core.standard.IppConstants;
import org.ipp4j.core.standard.Quality;
import org.ipp4j.core.standard.Tag;

/**
 * <p>
 * IPP Message Helper, provides essential methods to update
 * <code>IppMessage</code>.
 * 
 * @author cko
 * 
 */
public class IppMessageHelper {

	private IppMessage message;

	public IppMessageHelper(IppMessage message) {
		super();
		this.message = message;
	}

	public void setUri(String uri) {
		message.addAttribute(AttributeGroup.OPERATION, new Attribute(Tag.URI,
				IppConstants.NAME_PRINTER_URI, uri));
	}

	public void setCopies(int copies) {
		message.addAttribute(AttributeGroup.JOB, new Attribute(Tag.INTEGER,
				IppConstants.NAME_COPIES, copies));
	}

	public void setMimeType(String mimeType) {
		message.addAttribute(AttributeGroup.OPERATION, new Attribute(
				Tag.MIMETYPE, IppConstants.NAME_DOCUMENT_FORMAT, mimeType));

	}

	public void setLanguage(String language) {
		message.addAttribute(AttributeGroup.OPERATION, new Attribute(
				Tag.LANGUAGE, IppConstants.NAME_ATTRIBUTES_NATURAL_LANGUAGES,
				language));
	}

	public void setCharset(String charset) {
		message.addAttribute(AttributeGroup.OPERATION, new Attribute(
				Tag.CHARSET, IppConstants.NAME_ATTRIBUTES_CHARSET, charset));
	}

	public void setPrintQuality(Quality quality) {
		message.addAttribute(AttributeGroup.JOB, new Attribute(Tag.ENUM,
				IppConstants.NAME_PRINT_QUALITY, quality.getCode()));
	}

	public void setRequestUsername(String username) {
		message.addAttribute(AttributeGroup.OPERATION, new Attribute(Tag.NAME,
				IppConstants.NAME_REQUESTING_USER_NAME, username));
	}

	public void setJobName(String jobName) {
		message.addAttribute(AttributeGroup.OPERATION, new Attribute(Tag.NAME,
				IppConstants.NAME_JOB_NAME, jobName));
	}
}
